//============================================================================
// Name        : MutualInformation.cpp
// Author      : Erman Gurses
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <cv.h>
#include <opencv2/core/core.hpp>
#include <highgui.h>
#include <iostream>
#include <opencv2/gpu/gpu.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
using namespace std;
Mat rotate(Mat src, double angle)
{
    Mat dst;
    Point2f pt(src.cols/2, src.rows/2);
    Mat r = getRotationMatrix2D(pt, angle, 1.0);
    warpAffine(src, dst, r, Size(src.cols, src.rows),WARP_INVERSE_MAP);
    return dst;
}
int main( int argc, char** argv )
{

 Mat  imageGray,imageRGB, rotated , roi;

 imageGray= imread("/home/erman/cuda-workspace/ROI1/src/img_03225.bmp", CV_LOAD_IMAGE_GRAYSCALE);
 imageRGB  = imread("/home/erman/cuda-workspace/ROI1/src/img_03224.bmp", CV_LOAD_IMAGE_GRAYSCALE);

 int padding  = 100;

 int shift = 0;
 int shift1 = 1;

 //roi1 = rotate(imageRGB,  -30);
 //roi2 = roi1(Rect(0,0,200,200));



 //roi1 = imageRGB(Rect(0,0,200,200));
 //roi2 = rotate(roi1,  -30);



 Mat out = Mat::zeros(imageRGB.size(), imageRGB.type());
 Mat out1 = Mat::ones(imageRGB.size(), imageRGB.type());


// imageRGB(Rect(0,shift, imageRGB.cols,imageRGB.rows-shift)).copyTo(out(Rect(0,0,imageRGB.cols,imageRGB.rows-shift)));


 //imageRGB.copyTo(out(Rect(0,0,imageRGB.cols,imageRGB.rows-shift)),out1(Rect(0,0,imageRGB.cols,imageRGB.rows)));



 rotated = rotate(imageGray,  0);


 threshold(rotated, out, 0.0, 255,rotated.type() );


 imshow("rotated ",rotated);
 imshow("imageGray ",imageGray);


 roi = out & imageGray;

 imshow("out ",out);
 imshow("roi ",roi);


  waitKey(0);




  return 0;


}
